package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResSupplies;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ResSuppliesMapper {
    //插入一条resSupplies记录
    @Insert("insert into res_supplies (name,nums,department_id,team_id,category,type,function,location,manufacturer,production_time,maintain_time," +
            "create_by,create_time,enable) " +
            "values(#{name},#{nums},#{departmentId},#{teamId},#{category},#{type},#{function},#{location},#{manufacturer},#{productionTime},#{maintainTime},#{createBy},#{createTime},#{enable})")
    boolean insert(ResSupplies resSupplies);

    //通过id设置一条记录为不可用
    @Update("update res_supplies set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_supplies set name=#{name},nums=#{nums},department_id=#{departmentId}," +
            "team_id=#{teamId},category=#{category},type=#{type},function=#{function},location=#{location},manufacturer=#{manufacturer},production_time=#{productionTime},maintain_time=#{maintainTime}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResSuppliesById(ResSupplies resSupplies);

    //查找符合id字段的记录
    @Select("select id,name,nums,department_id,team_id,category,type,function,location,manufacturer,production_time,maintain_time,create_by,create_time,update_by,update_time,enable" +
            " from res_supplies where id =#{id} and enable=1")
    ResSupplies getResSuppliesById(Long id);

    //查找所有记录
    @Select("select id,name,nums,department_id,team_id,category,type,function,location,manufacturer,production_time,maintain_time,create_by,create_time,update_by,update_time,enable" +
            " from res_supplies where enable=1")
    List<ResSupplies> selectAll();
}